#pragma once


#include"Hash.h"

template<class K,class T>
class Map
{
	struct mapofT
	{
		const K& operator()(const pair<K, T>& kv)
		{
			return kv.first;
		}
	};
public:

	typedef typename HashTable<K, pair<K, T>, mapofT>::iterator iterator;
	typedef typename HashTable<K, pair<K, T>, mapofT>::const_iterator const_iterator;
	pair<iterator,bool> insert(const pair<K, T>& kv)
	{
		return _ht.insert(kv);
	}
	T& operator[](const K& key)
	{
		pair<iterator, bool> ret = insert(make_pair(key, T()));
		return ret.first->second;
	}
	
	iterator begin()
	{
		return _ht.begin();
	}
	iterator end()
	{
		return _ht.end();
	}

	const_iterator begin()const
	{
		return _ht.begin();
	}
	const_iterator end()const
	{
		return _ht.end();
	}


private:

	HashTable<K, pair<K, T>, mapofT> _ht;
};